import sys
import random

instancias = 10
K = 21
N = 50
M = 100

for k in [5,10,15,20]:
    n = N
    m = M
    arquivo = open("input_%d_%d_%d.txt" % (k, n, m), "w")
    for i in xrange(instancias):
        arquivo.write("%d %d %d\n" % (k, n, m))
        for i in xrange(n):
            arquivo.write("%d %d\n" % (random.randint(int(m/n), int(m*0.8)), random.randint(1, 1000)))
    arquivo.write("0 0 0\n")
    arquivo.close()
    
for n in [10, 20, 30, 40, 50]:
    k = K
    m = M
    arquivo = open("input_%d_%d_%d.txt" % (k, n, m), "w")
    for i in xrange(instancias):
        arquivo.write("%d %d %d\n" % (k, n, m))
        for i in xrange(n):
            arquivo.write("%d %d\n" % (random.randint(int(m/n), int(m*0.8)), random.randint(1, 1000)))
    arquivo.write("0 0 0\n")
    arquivo.close()
    
for m in [20, 40, 60, 80, 100]:
    k = K
    n = N
    arquivo = open("input_%d_%d_%d.txt" % (k, n, m), "w")
    for i in xrange(instancias):
        arquivo.write("%d %d %d\n" % (k, n, m))
        for i in xrange(n):
            arquivo.write("%d %d\n" % (random.randint(int(m/n), int(m*0.8)), random.randint(1, 1000)))
    arquivo.write("0 0 0\n")
    arquivo.close()
